package com.duoshu.grj.sosoliuda.upload;

import android.util.Log;

import com.alibaba.sdk.android.vod.upload.VODSVideoUploadCallback;

/**
 * 短视频上传回调类
 */

public class SnapVideoUploader implements VODSVideoUploadCallback {

    private SnapVideoUploadCallback callback;

    public SnapVideoUploader(){
    }

    public SnapVideoUploader(SnapVideoUploadCallback callback){
        this.callback = callback;
    }

    @Override
    public void onUploadSucceed(String videoId, String imageUrl) {
        Log.d("snapvideo","onUploadSucceed"+ "videoId:"+ videoId + "imageUrl" + imageUrl);
        callback.onUploadSucceed(videoId, imageUrl);
    }

    @Override
    public void onUploadFailed(String code, String message) {
        Log.d("snapvideo","onUploadFailed" + "code" + code + "message" + message);
        callback.onUploadFailed(code, message);
    }

    @Override
    public void onUploadProgress(long uploadedSize, long totalSize) {
        Log.d("snapvideo","onUploadProgress" + uploadedSize * 100 / totalSize);//运行在子线程中
        callback.onUploadProgress(uploadedSize, totalSize);
    }

    @Override
    public void onSTSTokenExpried() {
        Log.d("snapvideo","onSTSTokenExpried");
    }

    @Override
    public void onUploadRetry(String code, String message) {
        //上传重试的提醒
        Log.d("snapvideo","onUploadRetry" + "code" + code + "message" + message);
    }

    @Override
    public void onUploadRetryResume() {
        //上传重试成功的回调.告知用户重试成功
        Log.d("snapvideo","onUploadRetryResume");
    }

    public void setCallback(SnapVideoUploadCallback callback){
        this.callback = callback;
    }
}
